RTrack Analysis

Jonas Wagner

2021-06-13


Importing Data

Here a multicore CPU cluster is opened to reduce experiment reading times. This cluster is closed after the execution of the code.

cluster = parallel::makeCluster(rep("localhost", parallel::detectCores()), type = "SOCK")
experiment = Rtrack::read_experiment("Experiment_description2.xlsx", format = "Excel", cluster = cluster) 
parallel::stopCluster(cluster)

Analysis of experiment metrics

These metrics can be compared and extracted from the pure track files.

experiment$summary.variables
 [1] "path.length"                    "mean.velocity"                 
 [3] "sd.velocity"                    "total.time"                    
 [5] "latency.to.goal"                "goal.crossings"                
 [7] "old.goal.crossings"             "coverage"                      
 [9] "mean.d.centroid"                "mean.d.goal"                   
[11] "mean.d.old.goal"                "mean.d.origin"                 
[13] "sd.d.centroid"                  "sd.d.goal"                     
[15] "sd.d.old.goal"                  "sd.d.origin"                   
[17] "centroid.goal.displacement"     "centroid.old.goal.displacement"
[19] "mean.initial.heading.error"     "initial.trajectory.error"      
[21] "initial.reversal.error"         "turning"                       
[23] "turning.absolute"               "efficiency"                    
[25] "roaming.entropy"                "time.in.zone.pool"             
[27] "time.in.zone.wall"              "time.in.zone.far.wall"         
[29] "time.in.zone.annulus"           "time.in.zone.goal"             
[31] "time.in.zone.old.goal"          "time.in.zone.n.quadrant"       
[33] "time.in.zone.e.quadrant"        "time.in.zone.s.quadrant"       
[35] "time.in.zone.w.quadrant"       

back to top

par(mfrow = c(2, 2))
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Strain", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Age_group", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "Housing", exclude.probe = TRUE,lwd = 2)
Rtrack::plot_variable("path.length", experiment = experiment, factor = "All", exclude.probe = TRUE,lwd = 2)

Note that the probe trials have been omitted from these plots.

back to top


Heatmap

wt.metrics = experiment$metrics[experiment$factors$Strain == "WT" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4|
experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
dTg.metrics = experiment$metrics[experiment$factors$Strain == "dTg" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
APP.metrics = experiment$metrics[experiment$factors$Strain == "APPswe" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
PS1.metrics = experiment$metrics[experiment$factors$Strain == "PS1dE9" &
(experiment$factors$`_Day` == 1 | experiment$factors$`_Day` == 2 | experiment$factors$`_Day` == 3 | experiment$factors$`_Day` == 4| experiment$factors$`_Day` == 5| experiment$factors$`_Day` == 6)]
par(mfrow = c(2, 2))
Rtrack::plot_density(wt.metrics, title = "wt Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTg.metrics, title = "dTg Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APP.metrics, title = "APPswe Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1.metrics, title = "PS1dE9 Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

back to top


Heatmap_reversal

wtr.metrics = experiment$metrics[experiment$factors$Strain == "WT" &
                                           (experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
dTgr.metrics = experiment$metrics[experiment$factors$Strain == "dTg" &
                                            (experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
APPr.metrics = experiment$metrics[experiment$factors$Strain == "APPswe" &
                                  (experiment$factors$`_Day` ==7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
PS1r.metrics = experiment$metrics[experiment$factors$Strain == "PS1dE9" &
                                   (experiment$factors$`_Day` == 7 | experiment$factors$`_Day` == 8 | experiment$factors$`_Day` == 9 | experiment$factors$`_Day` == 10)]
par(mfrow = c(2, 2))
Rtrack::plot_density(wtr.metrics, title = "WT_reversal Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgr.metrics, title = "dTg_reversal Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPr.metrics, title = "APPswe_reversal Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1r.metrics, title = "PS1dE9_reversal Heatmap",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

back to top


Strategies

Calling strategies

strategies = Rtrack::call_strategy(experiment$metrics)

Thresholding strategies

limits called strategies to those, where confidence is greater than 40%

dim(Rtrack::threshold_strategies(strategies, 0.4)$calls)
[1] 4203   12

back to top


Plotting strategies of all age groups combined

par(mfrow = c(2, 2))
Rtrack::plot_strategies(strategies, experiment = experiment, factor = "Strain",
    exclude.probe = TRUE)

back to top


Plotting thresholded strategies of all age groups combined

par(mfrow = c(2, 2))
Rtrack::plot_strategies(Rtrack::threshold_strategies(strategies, 0.4), experiment = experiment,
                        factor = "Strain", exclude.probe = TRUE)

back to top


Saving the results

Here we export the results of the analyzed Track Files into a data.frame, to analyse them further.

results = Rtrack::export_results(experiment)
datatable(results, rownames = FALSE, filter="top", options = list(pageLength = 5, scrollX=T) )

back to top


OLD Graphs

Plotting with ggplot2

library(ggplot2)
library(readxl)
Results=read_excel("Results3.xlsx", col_types=c("text","text","text","text","text","text","logical","numeric","text","text","text","numeric","text","numeric","text","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric"))
ggplot(Results, aes(x=`_Day`,y=path.length,color=factor(Strain)))+geom_jitter()

Results
# A tibble: 5,960 x 60
   Track_ID `_TargetID` `_Day` `_Trial` `_Arena`    Condition Probe Trial Strain
   <chr>    <chr>       <chr>  <chr>    <chr>       <chr>     <lgl> <dbl> <chr> 
 1 Track_4  60-911      1      1        Arena_SW.t~ WT_STD    FALSE     4 WT    
 2 Track_8  60-293      1      1        Arena_SW.t~ WT_STD    FALSE     8 WT    
 3 Track_9  60-296      1      1        Arena_SW.t~ WT_STD    FALSE     9 WT    
 4 Track_10 60-333      1      1        Arena_SW.t~ dTg_STD   FALSE    10 dTg   
 5 Track_14 60-911      1      2        Arena_SW.t~ WT_STD    FALSE    14 WT    
 6 Track_18 60-293      1      2        Arena_SW.t~ WT_STD    FALSE    18 WT    
 7 Track_19 60-296      1      2        Arena_SW.t~ WT_STD    FALSE    19 WT    
 8 Track_20 60-333      1      2        Arena_SW.t~ dTg_STD   FALSE    20 dTg   
 9 Track_24 60-911      1      3        Arena_SW.t~ WT_STD    FALSE    24 WT    
10 Track_28 60-293      1      3        Arena_SW.t~ WT_STD    FALSE    28 WT    
# ... with 5,950 more rows, and 51 more variables: Housing <chr>,
#   Age_group <chr>, Age_months <dbl>, All <chr>, strategy <dbl>, name <chr>,
#   confidence <dbl>, 1 <dbl>, 2 <dbl>, 3 <dbl>, 4 <dbl>, 5 <dbl>, 6 <dbl>,
#   7 <dbl>, 8 <dbl>, 9 <dbl>, path.length <dbl>, mean.velocity <dbl>,
#   sd.velocity <dbl>, total.time <dbl>, latency.to.goal <dbl>,
#   goal.crossings <dbl>, old.goal.crossings <dbl>, coverage <dbl>,
#   mean.d.centroid <dbl>, mean.d.goal <dbl>, mean.d.old.goal <dbl>,
#   mean.d.origin <dbl>, sd.d.centroid <dbl>, sd.d.goal <dbl>,
#   sd.d.old.goal <dbl>, sd.d.origin <dbl>, centroid.goal.displacement <dbl>,
#   centroid.old.goal.displacement <dbl>, mean.initial.heading.error <dbl>,
#   initial.trajectory.error <dbl>, initial.reversal.error <dbl>,
#   turning <dbl>, turning.absolute <dbl>, efficiency <dbl>,
#   roaming.entropy <dbl>, time.in.zone.pool <dbl>, time.in.zone.wall <dbl>,
#   time.in.zone.far.wall <dbl>, time.in.zone.annulus <dbl>,
#   time.in.zone.goal <dbl>, time.in.zone.old.goal <dbl>,
#   time.in.zone.n.quadrant <dbl>, time.in.zone.e.quadrant <dbl>,
#   time.in.zone.s.quadrant <dbl>, time.in.zone.w.quadrant <dbl>

back to top

CAREFUL!!! The graphs below still include the probe trials (day 7 trial 1). To remove them add: Probe==‘FALSE’ to filter


Path Length Graphs

WT_STD=filter(Results, Strain=='WT'&Housing=='STD')
dTg_STD=filter(Results, Strain=='dTg'&Housing=='STD')
APP_STD=filter(Results, Strain=='APPswe'&Housing=='STD')
PS_STD=filter(Results, Strain=='PS1dE9'&Housing=='STD')
WT_ENR=filter(Results, Strain=='WT'&Housing=='ENR')
dTg_ENR=filter(Results, Strain=='dTg'&Housing=='ENR')
APP_ENR=filter(Results, Strain=='APPswe'&Housing=='ENR')
PS_ENR=filter(Results, Strain=='PS1dE9'&Housing=='ENR')
par(mfrow = c(2, 4))

WT_STD %>%
  mutate(WT_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
  ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
    labs(x="Day",
       y="Average Path length",
       title="Mean Path length WT STD")+scale_fill_jco()

dTg_STD  %>%
mutate(dTg_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length dTg STD")+scale_fill_jco()

APP_STD  %>%
mutate(APP_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length APPswe1 STD")+scale_fill_jco()

PS_STD  %>%
mutate(PS_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length PS1dE9 STD")+scale_fill_jco()

WT_ENR  %>%
mutate(WT_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length WT ENR")+scale_fill_jco()

dTg_ENR  %>%
mutate(dTg_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length dTg ENR")+scale_fill_jco()

APP_ENR  %>%
mutate(APP_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length APPswe1 ENR")+scale_fill_jco()

PS_ENR  %>%
mutate(PS_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length PS1dE9 ENR")+scale_fill_jco()+
  facet_wrap(~Age_group)

back to top


Latency Graphs

WT_STD %>%
  mutate(WT_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
  ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
    labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s WT STD")+scale_fill_jco()

dTg_STD  %>%
mutate(dTg_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s dTg STD")+scale_fill_jco()

APP_STD  %>%
mutate(APP_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s APPswe1 STD")+scale_fill_jco()

PS_STD  %>%
mutate(PS_STD, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s PS1dE9 STD")+scale_fill_jco()

WT_ENR  %>%
mutate(WT_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s WT ENR")+scale_fill_jco()

dTg_ENR  %>%
mutate(dTg_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s dTg ENR")+scale_fill_jco()

APP_ENR  %>%
mutate(APP_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s APPswe1 ENR")+scale_fill_jco()

PS_ENR  %>%
mutate(PS_ENR, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=latency.to.goal, fill=Age_group))+geom_boxplot()+
  labs(x="Day",
       y="Average Latency in s",
       title="Mean Latency in s PS1dE9 ENR")+scale_fill_jco()+
  facet_wrap(~Age_group)

back to top


UPDATED Graphs

Heatmap_probe

par(mfrow = c(2, 2))
Rtrack::plot_density(wtp.metrics, title = "WT Probe Heatmap 3-25mo",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgp.metrics, title = "dTg Probe Heatmap 3-25mo",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPp.metrics, title = "APPswe Probe Heatmap 3-25mo",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1p.metrics, title = "PS1dE9 Probe Heatmap 3-25mo",
                     col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

par(mfrow = c(2, 4))
Rtrack::plot_density(wtpstd.metrics, title = "WT Probe Heatmap STD 3-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd.metrics, title = "dTg Probe Heatmap STD 3-25mo",    col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpstd.metrics, title = "APPswe Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1pstd.metrics, title = "PS1dE9 Probe Heatmap STD 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr.metrics, title = "WT Probe Heatmap ENR 3-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr.metrics, title = "dTg Probe Heatmap ENR 3-25mo",    col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr.metrics, title = "APPswe Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1penr.metrics, title = "PS1dE9 Probe Heatmap ENR 3-25mo", col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

WT -> dTg -> APPswe -> PS1dE9

back to top

par(mfrow = c(1, 3))
###########WT_Probe##########
Rtrack::plot_density(wtpstd3.metrics, title = "WT Probe Heatmap STD 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpstd14.metrics, title = "WT Probe Heatmap STD 13-14mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpstd25.metrics, title = "WT Probe Heatmap STD 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

Rtrack::plot_density(wtpenr3.metrics, title = "WT Probe Heatmap ENR 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr14.metrics, title = "WT Probe Heatmap ENR 13-14mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(wtpenr25.metrics, title = "WT Probe Heatmap ENR 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

###########dTg_Probe##########
Rtrack::plot_density(dTgpstd3.metrics, title = "dTg Probe Heatmap STD 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd14.metrics, title = "dTg Probe Heatmap STD 13-14mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpstd25.metrics, title = "dTg Probe Heatmap STD 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

Rtrack::plot_density(dTgpenr3.metrics, title = "dTg Probe Heatmap ENR 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr14.metrics, title = "dTg Probe Heatmap ENR 13-14mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(dTgpenr25.metrics, title = "dTg Probe Heatmap ENR 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

###########APP_Probe##########
Rtrack::plot_density(APPpstd3.metrics, title = "APPswe Probe Heatmap STD 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(APPpstd14.metrics, title = "APPswe Probe Heatmap STD 13-14mo",
#  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpstd25.metrics, title = "APPswe Probe Heatmap STD 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr3.metrics, title = "APPswe Probe Heatmap ENR 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

#Rtrack::plot_density(APPpenr14.metrics, title = "APPswe Probe Heatmap ENR 13-14mo",
#  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(APPpenr25.metrics, title = "APPswe Probe Heatmap ENR 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
###########PS1_Probe##########
Rtrack::plot_density(PS1pstd3.metrics, title = "PS1dE9 Probe Heatmap STD 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(PS1pstd14.metrics, title = "PS1dE9 Probe Heatmap STD 13-14mo",
#  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1pstd25.metrics, title = "PS1dE9 Probe Heatmap STD 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

Rtrack::plot_density(PS1penr3.metrics, title = "PS1dE9 Probe Heatmap ENR 3mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
#Rtrack::plot_density(PS1penr14.metrics, title = "PS1dE9 Probe Heatmap ENR 13-14mo",
#  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))
Rtrack::plot_density(PS1penr25.metrics, title = "PS1dE9 Probe Heatmap ENR 17-25mo",
  col = colorRampPalette(c("#000C9E", "#00FEF6", "#FE009E"))(100))

back to top


Path Length Graphs

mo3=filter(Results, Age_group=='3')
mo14=filter(Results, Age_group=='13-14')
mo25=filter(Results, Age_group=='17-25')

mo3 %>%
  mutate(mo3, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
  ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
    labs(x="Day",
       y="Average Path length",
       title="Mean Path length 3mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))

mo14  %>%
mutate(mo14, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length 13-14mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))

mo25  %>%
mutate(mo25, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=path.length, fill=Condition))+geom_boxplot()+
  labs(x="Day",
       y="Average Path length",
       title="Mean Path length 17-25mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#6c7ed7", "dTg_STD" = "#909ef3","WT_ENR" = "#9f48a3", "WT_STD" = "#ce73cf","APPswe_ENR" = "#c85632", "APPswe_STD" = "#e9724b","PS1dE9_ENR" = "#9f9201", "PS1dE9_STD" = "#cab95b"))

back to top

Boxplot explanation:
Middle line in box -> Median
Box -> shows middle 50% of data(Distance between 1. and 3. Quartil)
Whisker(vertikal lines) -> show upper/lower 25% of data w/o outliers
Points -> outlier


Velocity (Mean) Graphs

mo3=filter(Results, Age_group=='3')
mo14=filter(Results, Age_group=='13-14')
mo25=filter(Results, Age_group=='17-25')

mo3 %>%
  mutate(mo3, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
  ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
    labs(x="Day",
       y="Average Velocity",
       title="Mean Velocity 3mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))

mo14  %>%
mutate(mo14, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
  labs(x="Day",
       y="Average Velocity",
       title="Mean Velocity 13-14mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#ad5fc9", "dTg_STD" = "#bc91cc","WT_ENR" = "#6eca64", "WT_STD" = "#98cc93","APPswe_ENR" = "#d6564b", "APPswe_STD" = "#db867f","PS1dE9_ENR" = "#918730", "PS1dE9_STD" = "#c5b740"))

mo25  %>%
mutate(mo25, `_Day`=fct_relevel(`_Day`,"1","2","3","4","5","6","7","8","9","10"))%>%
ggplot(aes(x=`_Day`,y=mean.velocity, fill=Condition))+geom_boxplot()+
  labs(x="Day",
       y="Average Velocity",
       title="Mean Velocity 17-25mo mice")+scale_fill_manual(values = c("dTg_ENR" = "#6c7ed7", "dTg_STD" = "#909ef3","WT_ENR" = "#9f48a3", "WT_STD" = "#ce73cf","APPswe_ENR" = "#c85632", "APPswe_STD" = "#e9724b","PS1dE9_ENR" = "#9f9201", "PS1dE9_STD" = "#cab95b"))

back to top


Strategy (Thresholded) Graphs

par(mfrow = c(2, 2))
Rtrack::plot_strategies(Rtrack::threshold_strategies(strategies, 0.4), experiment = experiment,
                        factor = "All", exclude.probe = TRUE)

back to top


Probe Trial Graphs

Probe Trial Number of Goals Crossings

mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Number of Goal Crossings",
       title="Probe Trial Number of Goal Crossings 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo14.probe  %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
  labs(x="Condition",
       y="Number of Goal Crossings",
       title="Probe Trial Number of Goal Crossings 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo25.probe  %>%
ggplot(aes(x=`Strain`,y=goal.crossings, fill=Housing))+geom_boxplot()+
  labs(x="Condition",
       y="Number of Goal Crossings",
       title="Probe Trial Number of Goal Crossings 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top


Probe Trial Number of former Goals Crossings

mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Number of old Goal Crossings",
       title="Probe Trial Number of former Goal Crossings 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Number of old Goal Crossings",
       title="Probe Trial Number of former Goal Crossings 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Number of Old Goal Crossings",
       title="Probe Trial Number of former Goal Crossings 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top


Probe Trial Time in old goal zone

mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=time.in.zone.old.goal, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Time in s",
       title="Probe Trial Time spent in old goal 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Time in s",
       title="Probe Trial Time spent in old goal 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=old.goal.crossings, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Time in s",
       title="Probe Trial Time spent in old goal 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top


Probe Trial Mean Initial heading error

mo3.probe=filter(Results, Age_group=='3'&`_Day`=='7'&`_Trial`=='1')
mo14.probe=filter(Results, Age_group=='13-14'&`_Day`=='7'&`_Trial`=='1')
mo25.probe=filter(Results, Age_group=='17-25'&`_Day`=='7'&`_Trial`=='1')

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in %??",
       title="Probe Trial Mean Initial heading error 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in %??",
       title="Probe Trial Mean Initial heading error 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.initial.heading.error`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Initial heading error in ???",
       title="Probe Trial Mean Initial heading error 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

back to top

Probe Trial Mean Distance old goal


3 Months

mo3.probe %>%
  ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Distance",
       title="Probe Trial Mean Distance old goal 3mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

13-14 Months

mo14.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Distance",
       title="Probe Trial Mean Distance old goal 13-14mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

17-25 Months

mo25.probe  %>%
  ggplot(aes(x=`Strain`,y=`mean.d.old.goal`, fill=Housing))+geom_boxplot()+
    labs(x="Condition",
       y="Distance",
       title="Probe Trial Mean Distance old goal 17-25mo mice")+scale_fill_manual(values = c("ENR"="#b3669e","STD"="#98984d"))

Arena Quadrant Problem


back to top

knitr::include_graphics("Watermaze_Setup.png")

In Ethovision those Quadrants are marked (NE, SE, SW, NW).
In contrast to that, the quadrants that can be analyzed with RTrack are called as below:
“time.in.zone.n.quadrant”
“time.in.zone.e.quadrant”
“time.in.zone.s.quadrant”
“time.in.zone.w.quadrant”

knitr::include_graphics("Watermaze_Quadrant.png")

t-Tests

t-Tests (time in old goal zone of probe trials) between Age Groups


3 / 13-14

t.test(mo3.probe$time.in.zone.old.goal,mo14.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  mo3.probe$time.in.zone.old.goal and mo14.probe$time.in.zone.old.goal
t = 0.41802, df = 55.572, p-value = 0.6775
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.4742248  0.7242732
sample estimates:
mean of x mean of y 
 1.248872  1.123847 

3 / 17-25

t.test(mo3.probe$time.in.zone.old.goal,mo25.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  mo3.probe$time.in.zone.old.goal and mo25.probe$time.in.zone.old.goal
t = -0.76178, df = 53.252, p-value = 0.4496
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.8365670  0.3759891
sample estimates:
mean of x mean of y 
 1.248872  1.479161 

13-14 / 17-25

t.test(mo14.probe$time.in.zone.old.goal,mo25.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  mo14.probe$time.in.zone.old.goal and mo25.probe$time.in.zone.old.goal
t = -0.96822, df = 62.942, p-value = 0.3366
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -1.0886658  0.3780395
sample estimates:
mean of x mean of y 
 1.123847  1.479161 

no significance between the overall groups


t-Tests (time in old goal zone of probe trials) between Strains & Housings of Age Group 17-25


17-25 WT STD/ENR

WTS.mo25.probe=filter(mo25.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo25.probe=filter(mo25.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo25.probe$time.in.zone.old.goal,WTE.mo25.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  WTS.mo25.probe$time.in.zone.old.goal and WTE.mo25.probe$time.in.zone.old.goal
t = 1.2667, df = 15.225, p-value = 0.2243
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.5876549  2.3148994
sample estimates:
mean of x mean of y 
 2.196897  1.333275 

13-14 WT STD/ENR

WTS.mo14.probe=filter(mo14.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo14.probe=filter(mo14.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo14.probe$time.in.zone.old.goal,WTE.mo14.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  WTS.mo14.probe$time.in.zone.old.goal and WTE.mo14.probe$time.in.zone.old.goal
t = -0.4615, df = 11.792, p-value = 0.6528
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.172106  1.414007
sample estimates:
mean of x mean of y 
 1.278296  1.657345 

3 WT STD/ENR

WTS.mo3.probe=filter(mo3.probe, Strain=='WT'&`Housing`=='STD')
WTE.mo3.probe=filter(mo3.probe, Strain=='WT'&`Housing`=='ENR')
t.test(WTS.mo3.probe$time.in.zone.old.goal,WTE.mo3.probe$time.in.zone.old.goal)

    Welch Two Sample t-test

data:  WTS.mo3.probe$time.in.zone.old.goal and WTE.mo3.probe$time.in.zone.old.goal
t = 0.86513, df = 16.892, p-value = 0.3991
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.8315724  1.9866145
sample estimates:
mean of x mean of y 
 1.724105  1.146584 

no significance found


t-Tests (Path length of all trials) between Strains


17-25 WT/dTg

mo25.WT=filter(mo25, Strain=="WT")
mo25.dTg=filter(mo25, Strain=="dTg")
t.test(mo25.WT$path.length,mo25.dTg$path.length)

    Welch Two Sample t-test

data:  mo25.WT$path.length and mo25.dTg$path.length
t = -7.4557, df = 286.47, p-value = 1.067e-12
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -333.6846 -194.2992
sample estimates:
mean of x mean of y 
 667.5763  931.5682 

17-25 WT/PS1dE9

mo25.WT=filter(mo25, Strain=="WT")
mo25.PS=filter(mo25, Strain=="PS1dE9")
t.test(mo25.WT$path.length,mo25.PS$path.length)

    Welch Two Sample t-test

data:  mo25.WT$path.length and mo25.PS$path.length
t = -2.4789, df = 228.85, p-value = 0.0139
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -183.21674  -20.94064
sample estimates:
mean of x mean of y 
 667.5763  769.6550 

17-25 WT/APPswe

mo25.WT=filter(mo25, Strain=="WT")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.WT$path.length,mo25.AP$path.length)

    Welch Two Sample t-test

data:  mo25.WT$path.length and mo25.AP$path.length
t = -3.6486, df = 268.81, p-value = 0.0003167
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -217.38161  -65.00338
sample estimates:
mean of x mean of y 
 667.5763  808.7688 

17-25 PS1dE9/APPswe

mo25.PS=filter(mo25, Strain=="PS1dE9")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.PS$path.length,mo25.AP$path.length)

    Welch Two Sample t-test

data:  mo25.PS$path.length and mo25.AP$path.length
t = -0.7493, df = 357.63, p-value = 0.4542
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -141.77175   63.54414
sample estimates:
mean of x mean of y 
 769.6550  808.7688 

17-25 dTg/PS1dE9

mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="PS1dE9")
t.test(mo25.dTg$path.length,mo25.PS$path.length)

    Welch Two Sample t-test

data:  mo25.dTg$path.length and mo25.PS$path.length
t = 3.2506, df = 343.79, p-value = 0.001266
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  63.94184 259.88464
sample estimates:
mean of x mean of y 
 931.5682  769.6550 

17-25 dTg/APPswe

mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.dTg$path.length,mo25.AP$path.length)

    Welch Two Sample t-test

data:  mo25.dTg$path.length and mo25.AP$path.length
t = 2.5701, df = 380.87, p-value = 0.01055
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  28.85462 216.74425
sample estimates:
mean of x mean of y 
 931.5682  808.7688 

t-Tests (Latency to goal of all trials) between Strains


17-25 WT/dTg

mo25.WT=filter(mo25, Strain=="WT")
mo25.dTg=filter(mo25, Strain=="dTg")
t.test(mo25.WT$latency.to.goal,mo25.dTg$latency.to.goal)

    Welch Two Sample t-test

data:  mo25.WT$latency.to.goal and mo25.dTg$latency.to.goal
t = -1.2135, df = 75.087, p-value = 0.2287
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -7.80585  1.89582
sample estimates:
mean of x mean of y 
 21.66102  24.61604 

17-25 WT/PS1dE9

mo25.WT=filter(mo25, Strain=="WT")
mo25.PS=filter(mo25, Strain=="PS1dE9")
t.test(mo25.WT$latency.to.goal,mo25.PS$latency.to.goal)

    Welch Two Sample t-test

data:  mo25.WT$latency.to.goal and mo25.PS$latency.to.goal
t = 0.20491, df = 121.95, p-value = 0.838
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -3.458770  4.257498
sample estimates:
mean of x mean of y 
 21.66102  21.26166 

17-25 WT/APPswe

mo25.WT=filter(mo25, Strain=="WT")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.WT$latency.to.goal,mo25.AP$latency.to.goal)

    Welch Two Sample t-test

data:  mo25.WT$latency.to.goal and mo25.AP$latency.to.goal
t = -0.54994, df = 133.82, p-value = 0.5833
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -4.522667  2.554791
sample estimates:
mean of x mean of y 
 21.66102  22.64496 

17-25 PS1dE9/APPswe

mo25.PS=filter(mo25, Strain=="PS1dE9")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.PS$latency.to.goal,mo25.AP$latency.to.goal)

    Welch Two Sample t-test

data:  mo25.PS$latency.to.goal and mo25.AP$latency.to.goal
t = -0.56912, df = 180.51, p-value = 0.57
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -6.179354  3.412750
sample estimates:
mean of x mean of y 
 21.26166  22.64496 

17-25 dTg/PS1dE9

mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="PS1dE9")
t.test(mo25.dTg$latency.to.goal,mo25.PS$latency.to.goal)

    Welch Two Sample t-test

data:  mo25.dTg$latency.to.goal and mo25.PS$latency.to.goal
t = 1.1414, df = 127.49, p-value = 0.2558
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.460675  9.169433
sample estimates:
mean of x mean of y 
 24.61604  21.26166 

17-25 dTg/APPswe

mo25.dTg=filter(mo25, Strain=="dTg")
mo25.AP=filter(mo25, Strain=="APPswe")
t.test(mo25.dTg$latency.to.goal,mo25.AP$latency.to.goal)

    Welch Two Sample t-test

data:  mo25.dTg$latency.to.goal and mo25.AP$latency.to.goal
t = 0.69518, df = 118.95, p-value = 0.4883
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -3.643181  7.585335
sample estimates:
mean of x mean of y 
 24.61604  22.64496 

Logistic regression

Results table can be seen here

Strategy Legend

  • 1 - thigmotaxis
  • 2 - circling
  • 3 - random path
  • 4 - scanning
  • 5 - chaining
  • 6 - directed search
  • 7 - corrected search
  • 8 - direct path
  • 9 - perseverance

Strategies 1-5 are less hippocampus-dependent, ‘unspatial’ and therefore get strategy.class = 0. In contrast to that, strategies 6-9 are more hippocampus-dependent, ‘spatial’ and get strategy.class = 1 assigned.

All probabilities in the following codes relate to choosing strategy.class = 1.


setwd("C:/Google/Uni/Bachelorarbeit/R/Analysis")
logistic.data=read_excel("logistic.reg.xlsx")

Age group 17-25 Housing


logistic.data.1725=filter(logistic.data, Age_group1725=='1')

fitting different logistic regression models with increasing complexity
simple model including housing only

logreg.1725.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1725)

simple model including Strain only

logreg.1725.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1725)

additive model including all factors

logreg.1725.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1725)

interaction model including all factors

logreg.1725.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1725)

Model comparisons using the anova function

anova(logreg.1725.add.1b, logreg.1725.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1      1308     1775.6                          
2      1310     1811.7 -2  -36.096 1.452e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

model including Strain better than model including housing

anova(logreg.1725.add.2, logreg.1725.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1      1307     1774.6                     
2      1308     1775.6 -1  -1.0162   0.3134

adding factor housing does not improve the model

anova(logreg.1725.int, logreg.1725.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1      1304     1771.3                     
2      1308     1775.6 -4  -4.3588   0.3596

interaction model not better than additive model simple model including Strain only is the minimal adequate model

summary of minimal adequate model

summary(logreg.1725.add.1b)

Call:
glm(formula = strategy.class ~ Strain, family = binomial, data = logistic.data.1725)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.325  -1.222   1.037   1.037   1.475  

Coefficients:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept)   0.10318    0.14378   0.718 0.472979    
StraindTg    -0.78083    0.20945  -3.728 0.000193 ***
StrainPS1dE9 -0.03339    0.20966  -0.159 0.873472    
StrainWT      0.23739    0.16168   1.468 0.142040    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1813.9  on 1311  degrees of freedom
Residual deviance: 1775.6  on 1308  degrees of freedom
AIC: 1783.6

Number of Fisher Scoring iterations: 4
exp(coef(logreg.1725.add.1b))
 (Intercept)    StraindTg StrainPS1dE9     StrainWT 
   1.1086957    0.4580270    0.9671628    1.2679321 

impact of predictor “Strain”

pred.data <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pred.data$prob <- predict(logreg.1725.add.1b, newdata = pred.data, type = "response")
pred.data
  Strain      prob
1     WT 0.5843293
2    dTg 0.3367876
3 PS1dE9 0.5174419
4 APPswe 0.5257732

impact of predictor “housing”

pred.data2 <- data.frame(Housing=c("STD","ENR"))
pred.data2$prob <- predict(logreg.1725.add.1a, newdata = pred.data2, type = "response")
pred.data2
  Housing      prob
1     STD 0.5504451
2     ENR 0.5094044

Age group 13-14 Strain x Housing effects


logistic.data.1314=filter(logistic.data, Age_group1314=='1')

fitting different logistic regression models with increasing complexity simple model including housing only

logreg.1314.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1314)

simple model including Strain only

logreg.1314.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1314)

additive model including all factors

logreg.1314.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1314)

interaction model including all factors

logreg.1314.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1314)

model comparisons using the anova function

anova(logreg.1314.add.1b, logreg.1314.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1      1306     1724.2                     
2      1306     1804.4  0   -80.16         

no Df, same model fit?

anova(logreg.1314.add.2, logreg.1314.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)  
1      1305     1718.1                       
2      1306     1724.2 -1  -6.1765  0.01295 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

additive model shows significantly better fit (Pr=0.01295)

anova(logreg.1314.int, logreg.1314.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)   
1      1304     1712.2                        
2      1306     1724.2 -2  -11.999  0.00248 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

interaction model better than simple Strain model (Pr=0.00248) interaction model including Strain*Housing is the best fitting model

summary of minimal adequate model

summary(logreg.1314.int)

Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial, 
    data = logistic.data.1314)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.4842  -0.9285  -0.9253   1.1143   1.4525  

Coefficients:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)         -0.626772   0.118643  -5.283 1.27e-07 ***
HousingSTD           0.008426   0.167152   0.050   0.9598    
StrainWT             1.324112   0.163290   8.109 5.11e-16 ***
HousingSTD:StrainWT -0.555484   0.230430  -2.411   0.0159 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1811.7  on 1307  degrees of freedom
Residual deviance: 1712.3  on 1304  degrees of freedom
AIC: 1720.3

Number of Fisher Scoring iterations: 4
exp(coef(logreg.1314.int))
        (Intercept)          HousingSTD            StrainWT HousingSTD:StrainWT 
          0.5343137           1.0084617           3.7588467           0.5737945 

impact of predictor "Strain*Housing"

pred.data <- data.frame(Strain=c("WT", "WT","dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pred.data$prob <- predict(logreg.1314.int, newdata = pred.data, type = "response")
pred.data
  Strain Housing      prob
1     WT     STD 0.5375000
2     WT     ENR 0.6675978
3    dTg     STD 0.3501577
4    dTg     ENR 0.3482428

Age group 3 Strain x Housing


logistic.data.3=filter(logistic.data, Age_group3=='1')

fitting different logistic regression models with increasing complexity simple model including housing only

logreg.3.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.3)

simple model including Strain only

logreg.3.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.3)

additive model including all factors

logreg.3.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.3)

interaction model including all factors

logreg.3.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.3)

comparisons between model using the anova function

anova(logreg.3.add.1b, logreg.3.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1      3336     4458.5                          
2      3338     4516.0 -2  -57.513 3.245e-13 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

model with Strain only is really good (Pr=3.245e-13)

anova(logreg.3.add.2, logreg.3.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1      3335     4440.3                          
2      3336     4458.5 -1  -18.243 1.945e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

adding factor housing also has good fit (Pr=1.945e-5)

anova(logreg.3.int, logreg.3.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1      3332     4428.8                          
2      3336     4458.5 -4  -29.694 5.648e-06 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

interaction model better than additive model (Pr=5.648e-6) interaction model is the best

summary of Strain only model

summary(logreg.3.add.1b)

Call:
glm(formula = strategy.class ~ Strain, family = binomial, data = logistic.data.3)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.4508  -1.3122   0.9267   1.0483   1.2183  

Coefficients:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept)   0.31144    0.06899   4.514 6.35e-06 ***
StraindTg    -0.40719    0.09715  -4.192 2.77e-05 ***
StrainPS1dE9  0.31166    0.09914   3.143  0.00167 ** 
StrainWT      0.30702    0.10290   2.984  0.00285 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 4529.0  on 3339  degrees of freedom
Residual deviance: 4458.5  on 3336  degrees of freedom
AIC: 4466.5

Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.add.1b))  
 (Intercept)    StraindTg StrainPS1dE9     StrainWT 
   1.3653846    0.6655165    1.3656859    1.3593683 

summary of interaction model

summary(logreg.3.int)

Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial, 
    data = logistic.data.3)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.5713  -1.2014   0.8293   1.0221   1.2715  

Coefficients:
                         Estimate Std. Error z value Pr(>|z|)    
(Intercept)              0.571375   0.099833   5.723 1.04e-08 ***
HousingSTD              -0.515022   0.139153  -3.701 0.000215 ***
StraindTg               -0.567129   0.135864  -4.174 2.99e-05 ***
StrainPS1dE9             0.319191   0.145466   2.194 0.028217 *  
StrainWT                -0.008040   0.153664  -0.052 0.958274    
HousingSTD:StraindTg     0.292295   0.195814   1.493 0.135512    
HousingSTD:StrainPS1dE9  0.001266   0.200208   0.006 0.994953    
HousingSTD:StrainWT      0.610701   0.207830   2.938 0.003298 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 4529.0  on 3339  degrees of freedom
Residual deviance: 4428.8  on 3332  degrees of freedom
AIC: 4444.8

Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.int))
            (Intercept)              HousingSTD               StraindTg 
              1.7707006               0.5974872               0.5671514 
           StrainPS1dE9                StrainWT    HousingSTD:StraindTg 
              1.3760135               0.9919925               1.3394975 
HousingSTD:StrainPS1dE9     HousingSTD:StrainWT 
              1.0012672               1.8417220 

impact of predictor “Strain”

pred.data3 <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pred.data3$prob <- predict(logreg.3.add.1b, newdata = pred.data3, type = "response")
pred.data3
  Strain      prob
1     WT 0.6498674
2    dTg 0.4760793
3 PS1dE9 0.6509217
4 APPswe 0.5772358

impact of predictors “Strain x Housing”

pred.data3x <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data3x$prob <- predict(logreg.3.int, newdata = pred.data3x, type = "response")
pred.data3x
  Strain Housing      prob
1     WT     STD 0.6590389
2     WT     ENR 0.6372240
3    dTg     STD 0.4455959
4    dTg     ENR 0.5010616
5 PS1dE9     STD 0.5931034
6 PS1dE9     ENR 0.7090069
7 APPswe     STD 0.5140845
8 APPswe     ENR 0.6390805

The full overview of the logistic regression results table is here.

Age group 17-25 acquisition Strain


logistic.data.1725.acq=filter(logistic.data.1725, `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')

fitting different logistic regression models with increasing complexity
simple model including housing only

logreg.1725.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1725.acq)

simple model including Strain only

logreg.1725.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1725.acq)

additive model including all factors

logreg.1725.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1725.acq)

interaction model including all factors

logreg.1725.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1725.acq)

Model comparisons using the anova function

anova(logreg.1725.acq.add.1b, logreg.1725.acq.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1       788     1067.9                          
2       790     1088.0 -2  -20.051 4.427e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

model including Strain better than model including housing

anova(logreg.1725.acq.add.2, logreg.1725.acq.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df  Deviance Pr(>Chi)
1       787     1067.9                      
2       788     1067.9 -1 -0.016692   0.8972

adding factor housing does not improve the model

anova(logreg.1725.acq.int, logreg.1725.acq.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1       784     1063.0                     
2       788     1067.9 -4  -4.9469   0.2928
summary(logreg.1725.acq.int)

Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial, 
    data = logistic.data.1725.acq)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.1632  -1.1575  -0.8672   1.1974   1.8182  

Coefficients:
                        Estimate Std. Error z value Pr(>|z|)  
(Intercept)             -0.69315    0.30619  -2.264   0.0236 *
HousingSTD               0.63599    0.38851   1.637   0.1016  
StraindTg               -0.09097    0.40387  -0.225   0.8218  
StrainPS1dE9             0.59471    0.39935   1.489   0.1364  
StrainWT                 0.64619    0.33547   1.926   0.0541 .
HousingSTD:StraindTg    -1.29223    0.59810  -2.161   0.0307 *
HousingSTD:StrainPS1dE9 -0.70460    0.54826  -1.285   0.1987  
HousingSTD:StrainWT     -0.62265    0.43190  -1.442   0.1494  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1088.1  on 791  degrees of freedom
Residual deviance: 1063.0  on 784  degrees of freedom
AIC: 1079

Number of Fisher Scoring iterations: 4
exp(coef(logreg.1725.acq.int))
            (Intercept)              HousingSTD               StraindTg 
              0.5000000               1.8888889               0.9130435 
           StrainPS1dE9                StrainWT    HousingSTD:StraindTg 
              1.8125000               1.9082569               0.2746572 
HousingSTD:StrainPS1dE9     HousingSTD:StrainWT 
              0.4943049               0.5365216 

impact of predictor “Strain”

pred.data.17.acq <- data.frame(Strain=c("WT", "dTg", "PS1dE9", "APPswe"))
pred.data.17.acq$prob <- predict(logreg.1725.acq.add.1b, newdata = pred.data.17.acq, type = "response")
pred.data.17.acq
  Strain      prob
1     WT 0.4900222
2    dTg 0.2631579
3 PS1dE9 0.4678899
4 APPswe 0.4237288

Age group 17-25 reversal Strain


logistic.data.1725.rev=filter(logistic.data.1725, `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')

fitting different logistic regression models with increasing complexity
simple model including housing only

logreg.1725.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.1725.rev)

simple model including Strain only

logreg.1725.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.1725.rev)

additive model including all factors

logreg.1725.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.1725.rev)

interaction model including all factors

logreg.1725.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.1725.rev)

Model comparisons using the anova function

anova(logreg.1725.rev.add.1b, logreg.1725.rev.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1       516     643.08                          
2       518     662.36 -2   -19.28 6.509e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

model including Strain better than model including housing

anova(logreg.1725.rev.add.2, logreg.1725.rev.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1       515     641.11                     
2       516     643.08 -1  -1.9658   0.1609

adding factor housing does not improve the model

anova(logreg.1725.rev.int, logreg.1725.rev.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)   
1       512     627.21                        
2       516     643.08 -4  -15.869 0.003201 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

interaction model better than additive model

summary of minimal adequate model

summary(logreg.1725.rev.int)

Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial, 
    data = logistic.data.1725.rev)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.6567  -1.2049   0.7647   0.8340   1.6033  

Coefficients:
                        Estimate Std. Error z value Pr(>|z|)    
(Intercept)              0.79851    0.40139   1.989 0.046660 *  
HousingSTD              -0.04082    0.50895  -0.080 0.936071    
StraindTg               -1.75992    0.51715  -3.403 0.000666 ***
StrainPS1dE9            -0.73397    0.53877  -1.362 0.173105    
StrainWT                 0.28141    0.44533   0.632 0.527444    
HousingSTD:StraindTg     1.79069    0.71471   2.505 0.012229 *  
HousingSTD:StrainPS1dE9  0.76474    0.73051   1.047 0.295166    
HousingSTD:StrainWT     -0.16186    0.57128  -0.283 0.776929    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 665.61  on 519  degrees of freedom
Residual deviance: 627.21  on 512  degrees of freedom
AIC: 643.21

Number of Fisher Scoring iterations: 4
exp(coef(logreg.1725.rev.int))
            (Intercept)              HousingSTD               StraindTg 
              2.2222222               0.9600000               0.1720588 
           StrainPS1dE9                StrainWT    HousingSTD:StraindTg 
              0.4800000               1.3250000               5.9935897 
HousingSTD:StrainPS1dE9     HousingSTD:StrainWT 
              2.1484375               0.8505620 

impact of predictor “Strain”

pred.data.17.revs <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data.17.revs$prob <- predict(logreg.1725.rev.int, newdata = pred.data.17.revs, type = "response")
pred.data.17.revs
  Strain Housing      prob
1     WT     STD 0.7062500
2     WT     ENR 0.7464789
3    dTg     STD 0.6875000
4    dTg     ENR 0.2765957
5 PS1dE9     STD 0.6875000
6 PS1dE9     ENR 0.5161290
7 APPswe     STD 0.6808511
8 APPswe     ENR 0.6896552

Age group 13-14 acquisition Strain x Housing


logistic.data.acq.1314=filter(logistic.data.1314,  `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')

fitting different logistic regression models with increasing complexity simple model including housing only

logreg.1314.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.acq.1314)

simple model including Strain only

logreg.1314.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.acq.1314)

additive model including all factors

logreg.1314.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.acq.1314)

interaction model including all factors

logreg.1314.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.acq.1314)

comparisons between model using the anova function

anova(logreg.1314.acq.add.1b, logreg.1314.acq.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1       779     1014.5                     
2       779     1049.4  0  -34.833         

model with Strain only is really good (Pr=3.245e-13)

anova(logreg.1314.acq.add.2, logreg.1314.acq.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)  
1       778     1009.0                       
2       779     1014.5 -1  -5.5851  0.01811 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

adding factor housing also has good fit

anova(logreg.1314.acq.int, logreg.1314.acq.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)  
1       777     1008.2                       
2       779     1014.5 -2  -6.3566  0.04166 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

additive model better than interaction model additive model is the best

summary of interactive model

summary(logreg.1314.acq.int)

Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial, 
    data = logistic.data.acq.1314)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.2994  -1.0987  -0.7931   1.2582   1.6186  

Coefficients:
                    Estimate Std. Error z value Pr(>|z|)    
(Intercept)          -0.7916     0.1583  -5.001 5.70e-07 ***
HousingSTD           -0.2038     0.2278  -0.895    0.371    
StrainWT              1.0738     0.2100   5.112 3.18e-07 ***
HousingSTD:StrainWT  -0.2664     0.3033  -0.878    0.380    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1055.6  on 780  degrees of freedom
Residual deviance: 1008.2  on 777  degrees of freedom
AIC: 1016.2

Number of Fisher Scoring iterations: 4
exp(coef(logreg.1314.acq.int))
        (Intercept)          HousingSTD            StrainWT HousingSTD:StrainWT 
          0.4531250           0.8155922           2.9265367           0.7660990 

impact of predictors “Strain x Housing”

pred.data1314.acq <- data.frame(Strain=c("WT","WT", "dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pred.data1314.acq$prob <- predict(logreg.1314.acq.int, newdata = pred.data1314.acq, type = "response")
pred.data1314.acq
  Strain Housing      prob
1     WT     STD 0.4531250
2     WT     ENR 0.5700935
3    dTg     STD 0.2698413
4    dTg     ENR 0.3118280

Age group 13-14 reversal Strain x Housing


logistic.data.rev.1314=filter(logistic.data.1314,  `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')

fitting different logistic regression models with increasing complexity simple model including housing only

logreg.1314.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.rev.1314)

simple model including Strain only

logreg.1314.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.rev.1314)

additive model including all factors

logreg.1314.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.rev.1314)

interaction model including all factors

logreg.1314.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.rev.1314)

comparisons between model using the anova function

anova(logreg.1314.rev.add.1b, logreg.1314.rev.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1       525     659.45                     
2       525     710.30  0  -50.855         

model with Strain only is really good (Pr=3.245e-13)

anova(logreg.1314.rev.add.2, logreg.1314.rev.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1       524     658.28                     
2       525     659.45 -1  -1.1655   0.2803

adding factor housing also has good fit (Pr=1.945e-5)

anova(logreg.1314.rev.int, logreg.1314.rev.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)  
1       523     650.44                       
2       525     659.45 -2    -9.01  0.01105 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

interaction model better than additive model (Pr=5.648e-6) interaction model is the best

summary of interaction model

summary(logreg.1314.rev.int)

Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial, 
    data = logistic.data.rev.1314)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.8297  -1.1247   0.6444   0.9049   1.3508  

Coefficients:
                    Estimate Std. Error z value Pr(>|z|)    
(Intercept)          -0.3989     0.1810  -2.204  0.02754 *  
HousingSTD            0.2737     0.2533   1.081  0.27974    
StrainWT              1.8652     0.2799   6.664 2.67e-11 ***
HousingSTD:StrainWT  -1.0586     0.3805  -2.783  0.00539 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 711.87  on 526  degrees of freedom
Residual deviance: 650.44  on 523  degrees of freedom
AIC: 658.44

Number of Fisher Scoring iterations: 4
exp(coef(logreg.1314.rev.int))
        (Intercept)          HousingSTD            StrainWT HousingSTD:StrainWT 
          0.6710526           1.3148789           6.4575163           0.3469306 

impact of predictors “Strain x Housing”

pred.data1314.rev <- data.frame(Strain=c("WT","WT", "dTg","dTg"),Housing=c("STD","ENR","STD","ENR"))
pred.data1314.rev$prob <- predict(logreg.1314.rev.int, newdata = pred.data1314.rev, type = "response")
pred.data1314.rev
  Strain Housing      prob
1     WT     STD 0.6640625
2     WT     ENR 0.8125000
3    dTg     STD 0.4687500
4    dTg     ENR 0.4015748

Age group 3 acquisition Strain x Housing


logistic.data.acq.3=filter(logistic.data.3,  `_Day`=='1'|`_Day`=='2'|`_Day`=='3'|`_Day`=='4'|`_Day`=='5'|`_Day`=='6')

fitting different logistic regression models with increasing complexity simple model including housing only

logreg.3.acq.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.acq.3)

simple model including Strain only

logreg.3.acq.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.acq.3)

additive model including all factors

logreg.3.acq.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.acq.3)

interaction model including all factors

logreg.3.acq.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.acq.3)

comparisons between model using the anova function

anova(logreg.3.acq.add.1b, logreg.3.acq.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1      1989     2683.6                          
2      1991     2753.3 -2  -69.785 7.021e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

model with Strain only is really good (Pr=3.245e-13)

anova(logreg.3.acq.add.2, logreg.3.acq.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1      1988     2668.9                          
2      1989     2683.6 -1  -14.652 0.0001293 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

adding factor housing also has good fit (Pr=1.945e-5)

anova(logreg.3.acq.int, logreg.3.acq.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance  Pr(>Chi)    
1      1985     2653.5                          
2      1989     2683.6 -4  -30.063 4.752e-06 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

interaction model better than additive model (Pr=5.648e-6) interaction model is the best

summary of interaction model

summary(logreg.3.acq.int)

Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial, 
    data = logistic.data.acq.3)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.412  -1.234   0.960   1.089   1.624  

Coefficients:
                        Estimate Std. Error z value Pr(>|z|)    
(Intercept)              0.30111    0.12520   2.405 0.016175 *  
HousingSTD              -0.59571    0.17841  -3.339 0.000841 ***
StraindTg               -0.66816    0.17434  -3.832 0.000127 ***
StrainPS1dE9             0.23441    0.17942   1.307 0.191370    
StrainWT                -0.08980    0.19226  -0.467 0.640462    
HousingSTD:StraindTg    -0.04436    0.26255  -0.169 0.865840    
HousingSTD:StrainPS1dE9  0.19165    0.25270   0.758 0.448197    
HousingSTD:StrainWT      0.89318    0.26355   3.389 0.000701 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 2762.8  on 1992  degrees of freedom
Residual deviance: 2653.5  on 1985  degrees of freedom
AIC: 2669.5

Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.acq.int))
            (Intercept)              HousingSTD               StraindTg 
              1.3513514               0.5511724               0.5126506 
           StrainPS1dE9                StrainWT    HousingSTD:StraindTg 
              1.2641667               0.9141176               0.9566127 
HousingSTD:StrainPS1dE9     HousingSTD:StrainWT 
              1.2112495               2.4428887 

impact of predictors “Strain x Housing”

pred.data3.acq <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data3.acq$prob <- predict(logreg.3.acq.int, newdata = pred.data3.acq, type = "response")
pred.data3.acq
  Strain Housing      prob
1     WT     STD 0.6245211
2     WT     ENR 0.5526316
3    dTg     STD 0.2675439
4    dTg     ENR 0.4092527
5 PS1dE9     STD 0.5328185
6 PS1dE9     ENR 0.6307692
7 APPswe     STD 0.4268775
8 APPswe     ENR 0.5747126

Age group 3 reversal Strain x Housing


logistic.data.rev.3=filter(logistic.data.3,  `_Day`=='7'|`_Day`=='8'|`_Day`=='9'|`_Day`=='10')

fitting different logistic regression models with increasing complexity simple model including housing only

logreg.3.rev.add.1a <- glm(strategy.class ~ Housing, family = binomial, data = logistic.data.rev.3)

simple model including Strain only

logreg.3.rev.add.1b <- glm(strategy.class ~ Strain, family = binomial, data = logistic.data.rev.3)

additive model including all factors

logreg.3.rev.add.2 <- glm(strategy.class ~ Housing + Strain, family = binomial, data = logistic.data.rev.3)

interaction model including all factors

logreg.3.rev.int <- glm(strategy.class ~ Housing * Strain, family = binomial, data = logistic.data.rev.3)

comparisons between model using the anova function

anova(logreg.3.rev.add.1b, logreg.3.rev.add.1a, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Strain
Model 2: strategy.class ~ Housing
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1      1343     1614.9                     
2      1345     1618.3 -2  -3.3859    0.184

model with Strain only is really good (Pr=3.245e-13)

anova(logreg.3.rev.add.2, logreg.3.rev.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing + Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)  
1      1342     1609.6                       
2      1343     1614.9 -1   -5.326  0.02101 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

adding factor housing also has good fit (Pr=1.945e-5)

anova(logreg.3.rev.int, logreg.3.rev.add.1b, test="Chisq")
Analysis of Deviance Table

Model 1: strategy.class ~ Housing * Strain
Model 2: strategy.class ~ Strain
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)   
1      1339     1598.6                        
2      1343     1614.9 -4  -16.331 0.002606 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

interaction model better than additive model (Pr=5.648e-6) interaction model is the best

summary of interaction model

summary(logreg.3.rev.int)

Call:
glm(formula = strategy.class ~ Housing * Strain, family = binomial, 
    data = logistic.data.rev.3)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.8720  -1.4233   0.7836   0.8752   0.9500  

Coefficients:
                        Estimate Std. Error z value Pr(>|z|)    
(Intercept)               1.0234     0.1719   5.953 2.63e-09 ***
HousingSTD               -0.4410     0.2339  -1.886   0.0593 .  
StraindTg                -0.4617     0.2287  -2.019   0.0435 *  
StrainPS1dE9              0.5383     0.2643   2.036   0.0417 *  
StrainWT                  0.1501     0.2705   0.555   0.5790    
HousingSTD:StraindTg      0.7387     0.3282   2.251   0.0244 *  
HousingSTD:StrainPS1dE9  -0.3585     0.3481  -1.030   0.3031    
HousingSTD:StrainWT       0.1640     0.3549   0.462   0.6441    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1622.9  on 1346  degrees of freedom
Residual deviance: 1598.6  on 1339  degrees of freedom
AIC: 1614.6

Number of Fisher Scoring iterations: 4
exp(coef(logreg.3.rev.int))
            (Intercept)              HousingSTD               StraindTg 
              2.7826087               0.6433972               0.6302083 
           StrainPS1dE9                StrainWT    HousingSTD:StraindTg 
              1.7130208               1.1619792               2.0931950 
HousingSTD:StrainPS1dE9     HousingSTD:StrainWT 
              0.6987137               1.1781761 

impact of predictors “Strain x Housing”

pred.data3.rev <- data.frame(Strain=c("WT","WT", "dTg","dTg", "PS1dE9","PS1dE9", "APPswe","APPswe"),Housing=c("STD","ENR","STD","ENR","STD","ENR","STD","ENR"))
pred.data3.rev$prob <- predict(logreg.3.rev.int, newdata = pred.data3.rev, type = "response")
pred.data3.rev
  Strain Housing      prob
1     WT     STD 0.7102273
2     WT     ENR 0.7637795
3    dTg     STD 0.7025316
4    dTg     ENR 0.6368421
5 PS1dE9     STD 0.6818182
6 PS1dE9     ENR 0.8265896
7 APPswe     STD 0.6416185
8 APPswe     ENR 0.7356322

Results

Results table can be seen here

Strategy Overview plot

knitr::include_graphics("strategy.png")

Visualization results log. reg

library(plotly)
setwd("C:/Google/Uni/Bachelorarbeit/R/Analysis")
gg = ggplot(pred.data3x, aes(x=Strain, y=prob, color=Housing)) + 
  geom_jitter() + 
  labs(x="Strain", y="P(strategy.class 1)", title="Probability of class 1") 
ggplotly(gg)
probs=read_excel("results_logistic.xlsx")
x=c("WT","dTg","PS1dE9","APPswe")
y=c("STD","ENR","ACQ STD","ACQ ENR", "REV STD", "REV ENR")
z=rbind(
  c(0.1061947,-0.05573,0.0375,-0.1498423),
  c(-0.1507937,0.0186289,0.1675978,-0.1517572),
  c(0.1498674,0.1509217,0.0564133,0.1590389),
  c(-0.0239207,0.0772358,0.1177536,0.137224),
  c(-0.0544041,0.0931034,0.0140845,-0.0099778),
  c(0.0010616,0.2090069,0.1390805,-0.2368421)
)
z2=rbind(
  c(0,0,0,0),c(0,0,0,0),c(0,0,0,0),c(0,0,0,0),c(0,0,0,0),c(0,0,0,0))
  
ebene= plot_ly(type="surface", x=~x, y=~y, z=~z)
ebene= ebene %>% add_surface(z=~z2)
ebene= ebene %>% layout( title='Probability of Strategy class 1 in 3 months old mice')
ebene

Interactive plot created with plotly library.